package com.tools.web.interceptor.access;

import com.tools.common.object.Note;

import java.util.Objects;

/**
 * 权限验证拦截器所需参数配置项的包装类
 * */
@Note("权限验证拦截器所需参数配置项的包装类")
public class AccessSource {

    @Note("访问权限不足时访问给客户端的响应信息")
    private String accessFailResponseMessage;

    @Note("若开启了时间范围验证，且接口的开放时间还没到，就响应该信息")
    private String unreleasedResponseMessage;

    public AccessSource() {}

    public static AccessSource of() {
        return new AccessSource();
    }

    public String getAccessFailResponseMessage() {
        return accessFailResponseMessage;
    }

    public void setAccessFailResponseMessage(String accessFailResponseMessage) {
        this.accessFailResponseMessage = accessFailResponseMessage;
    }

    public String getUnreleasedResponseMessage() {
        return unreleasedResponseMessage;
    }

    public void setUnreleasedResponseMessage(String unreleasedResponseMessage) {
        this.unreleasedResponseMessage = unreleasedResponseMessage;
    }

    @Override
    public String toString() {
        return "AccessSource{" +
                "accessFailResponseMessage='" + accessFailResponseMessage + '\'' +
                ", unreleasedResponseMessage='" + unreleasedResponseMessage + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AccessSource source = (AccessSource) o;
        return Objects.equals(accessFailResponseMessage, source.accessFailResponseMessage) && Objects.equals(unreleasedResponseMessage, source.unreleasedResponseMessage);
    }

    @Override
    public int hashCode() {
        return Objects.hash(accessFailResponseMessage, unreleasedResponseMessage);
    }

    public AccessSource accessFailResponseMessage(String accessFailResponseMessage) {
        this.setAccessFailResponseMessage(accessFailResponseMessage);
        return this;
    }

    public AccessSource unreleasedResponseMessage(String unreleasedResponseMessage) {
        this.setUnreleasedResponseMessage(unreleasedResponseMessage);
        return this;
    }
}
